{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5ae1f093",
   "metadata": {},
   "source": [
    "-----------\n",
    "* 本学习记录人：戴祥哲\n",
    "* 学习时间：2021-12-02\n",
    "* week09\n",
    "* [参考文档](https://python.org/doc)\n",
    "* [徐老师博客](https://cnblogs.com/xuzhichao)\n",
    "-----------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "64c05cc0",
   "metadata": {},
   "source": [
    "## 回顾序列数据\n",
    "\n",
    "* range() 生成数值 ：(0,5)->[0,1,2,3,4]\n",
    "* list() 列表数据：['lihua','xiaoming','Alex']\n",
    "\n",
    "* 除了以上两个，还有一个特殊的序列数据：str 字符串\n",
    "\n",
    "> 1. 有 index 索引值\n",
    "> 2. 有 起始和终止值 以及 步长的概念\n",
    "> 3. 有 切片的概念 \n",
    "> 4. 用 in 查询成员的关系\n",
    "> 5. ...\n",
    "\n",
    "> 6. 总结 请查阅链接 [list,tuple,range](https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "7f5790d8",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "907962e7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Operation</th>\n",
       "      <th>Result</th>\n",
       "      <th>Notes</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>x in s</td>\n",
       "      <td>True if an item of s is equal to x, else False</td>\n",
       "      <td>(1)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>x not in s</td>\n",
       "      <td>False if an item of s is equal to x, else True</td>\n",
       "      <td>(1)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>s + t</td>\n",
       "      <td>the concatenation of s and t</td>\n",
       "      <td>(6)(7)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>s * n or n * s</td>\n",
       "      <td>equivalent to adding s to itself n times</td>\n",
       "      <td>(2)(7)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>s[i]</td>\n",
       "      <td>ith item of s, origin 0</td>\n",
       "      <td>(3)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>s[i:j]</td>\n",
       "      <td>slice of s from i to j</td>\n",
       "      <td>(3)(4)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>s[i:j:k]</td>\n",
       "      <td>slice of s from i to j with step k</td>\n",
       "      <td>(3)(5)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>len(s)</td>\n",
       "      <td>length of s</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>min(s)</td>\n",
       "      <td>smallest item of s</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>max(s)</td>\n",
       "      <td>largest item of s</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>s.index(x[, i[, j]])</td>\n",
       "      <td>index of the first occurrence of x in s (at or...</td>\n",
       "      <td>(8)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>s.count(x)</td>\n",
       "      <td>total number of occurrences of x in s</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               Operation                                             Result  \\\n",
       "0                 x in s     True if an item of s is equal to x, else False   \n",
       "1             x not in s     False if an item of s is equal to x, else True   \n",
       "2                  s + t                       the concatenation of s and t   \n",
       "3         s * n or n * s           equivalent to adding s to itself n times   \n",
       "4                   s[i]                            ith item of s, origin 0   \n",
       "5                 s[i:j]                             slice of s from i to j   \n",
       "6               s[i:j:k]                 slice of s from i to j with step k   \n",
       "7                 len(s)                                        length of s   \n",
       "8                 min(s)                                 smallest item of s   \n",
       "9                 max(s)                                  largest item of s   \n",
       "10  s.index(x[, i[, j]])  index of the first occurrence of x in s (at or...   \n",
       "11            s.count(x)              total number of occurrences of x in s   \n",
       "\n",
       "     Notes  \n",
       "0      (1)  \n",
       "1      (1)  \n",
       "2   (6)(7)  \n",
       "3   (2)(7)  \n",
       "4      (3)  \n",
       "5   (3)(4)  \n",
       "6   (3)(5)  \n",
       "7      NaN  \n",
       "8      NaN  \n",
       "9      NaN  \n",
       "10     (8)  \n",
       "11     NaN  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_html('https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range')[5]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2f27cae6",
   "metadata": {},
   "source": [
    "## 本周学习内容--序列数据值元组(tuple)\n",
    "\n",
    "> 1. 元组的概念\n",
    "> 2. 元组的性质\n",
    ">> 1. 具有序列的一般性质\n",
    ">> 2. **不可变型**\n",
    "> 3. 元组的形式:用原括号括起来的序列数据\n",
    ">> * (value1,value2,value3,...)\n",
    "> 4. 元组的一般方式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "be64e17c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'tuple'>\n",
      "(12345, 54321, 'hello！')\n"
     ]
    }
   ],
   "source": [
    "# 1. 一个变量赋值多个值，这些值将组成一个元组\n",
    "t = 12345,54321,\"hello！\"\n",
    "print(type(t))\n",
    "print(t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "bcf9ba9c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('Jack', 'Marry', 'Lihua')\n"
     ]
    }
   ],
   "source": [
    "# 2. 用元组的表现形式创建元组\n",
    "names = ('Jack','Marry','Lihua')\n",
    "print(names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "8375efb6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(88, 87, 88, 90, 91, 90, 92)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3. 元组的一般方法\n",
    "\n",
    "stud_成绩 =(88,87,88,90,91,90,92)\n",
    "stud_成绩"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "cb92ec8a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_成绩.count(88)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "d2573e2e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_成绩.index(87)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "3675421e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 元组案例\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "860c8f82",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=12, tm_mday=2, tm_hour=19, tm_min=26, tm_sec=31, tm_wday=3, tm_yday=336, tm_isdst=0)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "8eba5763",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function localtime in module time:\n",
      "\n",
      "localtime(...)\n",
      "    localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,\n",
      "                              tm_sec,tm_wday,tm_yday,tm_isdst)\n",
      "    \n",
      "    Convert seconds since the Epoch to a time tuple expressing local time.\n",
      "    When 'seconds' is not passed in, convert the current time instead.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(time.localtime)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "86ab6db6",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
